Repository navigation
fix(runtime): fail loud on unresolved aliases and missing stages (WO18 G3/G4) - #136
Merged
Merged
Conversation
WO18 G3/G4 from the merged four-runtime parity audit (maps
docs/parity/README.md, PR #275).
G3: an alias that resolves to nothing compiled to the empty matcher
(re: "", literal: ""), which matches at every string boundary and
silently splices the replacement text ("a" -> "XaX"). Raise
MapLogicError "Alias <name> not found" instead, mirroring ruby's
SystemConversionError and rs's load-time error. The parallel paths are
covered by the same raise: compileToLiteral/expandFromLiterals return
null, the block falls to the megaregexp path, and compileItem surfaces
the error there.
G4: requesting a stage the map doesn't have silently returned the
input, hiding map typos. Both executeStage and executeStageAsync now
raise MapLogicError "stage "<name>" not found in <system code>"
(rs's message shape). Run-target stages already raised.
API-visible change: callers who relied on the missing-stage no-op now
get MapLogicError (transliterate and transliterateAsync alike).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WO18 G3/G4 from the merged four-runtime parity audit (maps
docs/parity/README.md, PR #275): the ts runtime silently corruptedoutput on unresolved aliases and silently no-op'd on missing stages.
ruby raises named errors in both situations (rs too); this aligns ts.
src/runtime/compile-item.ts): an alias that resolves tonothing compiled to the EMPTY matcher (
re: "", which matches atevery string boundary), silently splicing the replacement text —
sub unknown_alias "X", input"a"gave"XaX","zzz"gave"XzXzXzX". Now raisesMapLogicError "Alias <name> not found"(ruby's message). The parallel paths inherit the raise: literal
expansion returns null, the block falls to the megaregexp path, and
the compile there surfaces the same error.
src/runtime/interpreter.ts): requesting an absent stagereturned the input unchanged, hiding map typos (
--stage mahnsilently "worked").
executeStageandexecuteStageAsyncnow raiseMapLogicErrorwith rs's message shape:stage "mahn" not found in <system code>. Missing run-target stages already raised.API-visible change (G4): callers who relied on the missing-stage
no-op now get
MapLogicError, intransliterateandtransliterateAsyncalike.Test plan
test/isc/fail-loud.test.tswritten first (red): unknownalias raised nothing; missing stage returned the input. After the
fix: 4/4 green, including the async path.
the clean branch immediately before the change; no pre-existing
failures).
tsc --noEmit, prettier all clean.maps scripts/parse-parity.mjs): output byte-identical to the origin/mainbaseline run (412/435, same divergence counts) — no grammar/parser
behavior change; no grammar files touched.
tst-g3-unknown-alias->MapLogicError Alias unknown_alias not found; missing stage ->MapLogicError stage "mahn" not found in T:...;tst-dir-upcasestill"A".